package com.srv.servlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ResponseResult {
	private static Log log = LogFactory.getLog(ResponseResult.class);
	/**
	 * 返回结果：成功
	 */
     public static final int RESULT_OK = 0;
     /**
      * 返回结果：失败
      */
     public static final int RESULT_FAIL = 1;
     /**
      * 返回结果
      */
     public int theResult = ResponseResult.RESULT_OK;
     /**
      * 消息体
      */
     public Object theMessageObj = null;
     /**
      * 转成Json字符串
      * @return
      */
     public String toJson(){       	 
    	 if(this.theMessageObj == null){    		 
    		 return theResult==ResponseResult.RESULT_OK?ConstText.JSON_R_OK.concat(ConstText.JSON_Brace_RIGHT):ConstText.JSON_R_FAIL.concat(ConstText.JSON_Brace_RIGHT);
    	 }
    	 try{
    		 return (new ResponseResult_Json(this)).toJson_utf8();
    	 }catch(Exception e){
    		 log.equals("error:"+e.getMessage());
    	 }
    	 return null;    	 
     }
}
